package uit.compile.lexical;

public class SourcePosition {
    public int charStart;//start position of token
    public int charFinish;//finish position of token
    public int lineStart;//start line number of token
    public int lineFinish;//end line number of token

    public SourcePosition(int cS, int cF, int lS, int lF) {
        charStart = cS;
        charFinish = cF;
        lineStart = lS;
        lineFinish = lF;
    }

    public SourcePosition() {
        charStart = 1;
        charFinish = 0;
        lineStart = 1;
        lineFinish = 1;
    }
    public SourcePosition(SourcePosition p)
    {
        charStart = p.charStart;
        charFinish = p.charFinish;
        lineStart = p.lineStart;
        lineFinish = p.lineFinish;	 	
    }
    public String toString() {
        return "charStart=" + String.valueOf(charStart) + " " + "charFinish=" + String.valueOf(charFinish) + " " + "lineStart=" + String.valueOf(lineStart) + " " + "lineFinish=" + String.valueOf(lineFinish);
    }
    public void newLine()
    {   	
    	lineStart = ++lineFinish;
    	charStart = 1;
    	charFinish = 0;
    }
    public void endToken()
    {
    	charStart = charFinish;
    	charFinish--;
    	lineStart = lineFinish;
    }
}
